// 1. 导入所需模块
import Vue from 'vue'
import VueRouter from 'vue-router'

import MyAbout from '@/components/MyAbout.vue'
import MyMovie from '@/components/MyMovie.vue'
import MyHome from '@/components/MyHome.vue'
import MySports from '@/components/MySports'

import AboutYou from '@/components/AboutYou'
import AboutMe from '@/components/AboutMe'

// 2. 调用 Vue.use() 函数，将 VueRouter 安装为 Vue 的插件
Vue.use(VueRouter)

// 3. 创建路由的实例对象
const router = new VueRouter({
  routes: [
    // 一条一条的规则，都写到这里。规则，就是hash地址 和 组件的对应关系
    { path: '/home', component: MyHome },
    { path: '/movie/:id/:name', component: MyMovie },
    { path: '/sport', component: MySports },
    {
      path: '/about', component: MyAbout, children: [
        // path表示hash地址，如果是一级，/about。如果是二级，/ 就不要加了
        // 会自动拼接成 /about/me   /about/you
        { path: 'me', component: AboutMe },
        { path: 'you', component: AboutYou }
      ]
    }
  ]
})

// 4. 导出路由的实例对象
export default router